<?php

	class StringUtils extends Base {
		
		public static function fromCamelCase($value) {
			$value[0] = strtolower($str[0]);
	    	$func = create_function('$c', 'return "_" . strtolower($c[1]);');
	    	return preg_replace_callback('/([A-Z])/', $func, $value);
		}
		
		public static function toCamelCase($value, $firstUpperCase = false) {
			if( $firstUpperCase ) {
	      		$value = ucfirst($value);
	    	}
	    	$func = create_function('$c', 'return strtoupper($c[1]);');
	    	return preg_replace_callback('/_([a-z])/', $func, $value);
		}
		
		public static function lcfirst($str) {
			return (string)(strtolower(substr($str,0,1)).substr($str,1));
		}
		
		public static function ucfirst($str) {
			return (string)(strtoupper(substr($str,0,1)).substr($str,1));
		}
		
		public static function replace($oldChar, $newChar, $text) {
			return str_replace($oldChar, $newChar, $text);
		}
		
	}
?>